<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
var formCategoryIdTemp="<c:out value='${synForm.formCategoryId }' />";
$(function(){
	
	hide_type_level();
	//添加验证
	//addValid();
	
	showHidePerson();
	//theValueOf();
	//保存按钮绑定事件
	$("#saveButton_Edit").click(function(){
		if($("#carCategoryForm").form('validate')){
			$(this).attr("disabled",true);
			save();
		}
	});
	
});


function theValueOf(){//显示值到前端
	var person = '${scheduleInfo.person}';
	var startime = '${scheduleInfo.startime}';
	var endtime = '${scheduleInfo.endtime}';
	$("#person_name_list_edit").val(person)
	$('#schedule_startime_Edit').datetimebox('setValue', formatterSDate(new Date(startime)));
    $('#schedule_endtime_Edit').datetimebox('setValue', formatterEDate(new Date(endtime)));
    
}

//隐藏显示人员信息框
function showHidePerson(){
	var judge = '${judge}';
	if(judge == 2){
		$("#personDiv1").show();
		$("#personDiv").hide();
	}else{
		$("#personDiv1").hide();
		$("#personDiv").show();
	}
}


function save(){
	var id = "${id}";
	var judge = '${judge}';
	var schedule_person = "";
	if(judge == 2){
		schedule_person = $("#schedule_person_edit").val();
	}else{
		schedule_person = $("#person_name_list_edit option:selected").text();
	}
	var schedule_type = $("#schedule_type_Edit").val();
	var schedule_level = $("#calendar_level_Edit").val();
	var schedule_startime = $("#schedule_startime_Edit").val();
	var schedule_endtime = $("#schedule_endtime_Edit").val();
	var schedule_theme = $("#schedule_theme_Edit").val();
	var schedule_content = $("#schedule_content_Edit").val();
	var uid = "${uuid}";
	var createPerson_uid = "${createPerson_uuid}";
	var updatePerson_uid = "${updatePerson_uuid}";
	if((id!="") && (uid!="") && (createPerson_uid!="") && (updatePerson_uid!="") && (schedule_person!="")  && (schedule_startime!="") && (schedule_endtime!="") && (schedule_theme!="") && (schedule_content!="")){
		$.ajax({
			type: "POST",
			url: "/document/schedule/write1",
			data: {id:id, uuid:uid, s_createPerson_uuid:createPerson_uid, s_updatePerson_uuid:updatePerson_uid, person:schedule_person, type:schedule_type, level:schedule_level, startime:schedule_startime, endtime:schedule_endtime, theme:schedule_theme, content:schedule_content},
			dataType: 'json',
			success: function(data){
				if(data.status == "200"){
					//$.messager.alert("提示","新增日程保存成功");
					parent.closeDialog();
				}else{
					$.messager.alert("提示","新增日程保存失败");
				}
				
			}
		});
	}else{
		$.messager.alert("提示","请填写完整！");
	}
}


//添加验证
function addValid(){
	//名称
	$("#carCategory").textbox({
	    required: true,
	    validType:'length[1,60]'
	});
	
	
	
	//排序号
	$("input[name='sequence']").numberbox({
		required: true,
		min:1,
	    precision:0
	});
}

function hide_type_level(){
	var lingdao = "${lingDao}";
	//if(lingdao == "0"){
	//	$("#hide_type_level").hide();
	//}
	var judge = '${judge}';
	if(judge == 2){
		if(lingdao == 1){
			$("#hide_type_level").show();
		}else{
			$("#hide_type_level").hide();
		}
	}else{
		$("#hide_type_level").show();
	}
}

